package room;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
import javax.swing.UIManager;

public class RoomCellRenderer extends JLabel implements ListCellRenderer {

	@Override
	public Component getListCellRendererComponent(JList list, Object value,
			int index, boolean isSelected, boolean cellHasFocus) {

		Room room = (Room) value;
	
		this.setText(room.toString());

		this.setOpaque(true);
		
		if(isSelected){
			this.setForeground(UIManager.getColor("List.selectionForeground"));  
			this.setBackground(UIManager.getColor("List.selectionBackground"));
		}
		else{
			this.setForeground(Color.BLACK);
			if(room.mode == 0){
				this.setBackground(new Color(133, 194, 255));
			}else if(room.mode == 1){
				this.setBackground(new Color(179, 179, 230));
			}else if(room.mode == 2){
				this.setBackground(new Color(133, 255, 194));
			}
			
			if(room.rule == 3){
				this.setBackground(new Color(230, 179, 230));
			}else if(room.rule == 4){
				this.setBackground(new Color(230, 230, 179));
			}
			
			if(room.enabledPriority || room.isNoCheckDeck || room.isNoShuffleDeck || (room.startLp != 8000 && room.mode != 2)){
				this.setBackground(new Color(255, 179, 179));
			}
			
		}

		return this;
	}


}
